/* Copyright  2009
   @Author
   Richard Changde Yin            e-mail yinchangde@hotmail.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/*
** filename : field/null.h
*
*/

#ifndef _SERVER_FIELD_NULL_H
#define _SERVER_FIELD_NULL_H

#include <field/str.h>

/*
 * Everything saved in this will disappear. It will always return NULL
 */

class Field_null :public Field_str {

  static unsigned char null[1];

public:

  using Field::store;
  using Field::val_str;
  using Field::cmp;
  using Field::val_int;

  Field_null(unsigned char *ptr_arg, uint32_t len_arg,
             enum utype unireg_check_arg, const char *field_name_arg,
             const CHARSET_INFO * const cs)
             :Field_str(ptr_arg, len_arg, null, 1,
                unireg_check_arg, field_name_arg, cs)
       {}

  enum_field_types type() const { return COLLAPSAR_TYPE_NULL;}

  inline int  store(const char *, uint32_t, const CHARSET_INFO * const)
          { null[0]=1; return 0; }
  inline int store(double)
          { null[0]=1; return 0; }
  inline int store(int64_t, bool)
          { null[0]=1; return 0; }
  inline int store_decimal(const db_decimal *)
          { null[0]=1; return 0; }
  inline int reset(void)
          { return 0; }
  inline double val_real(void)
          { return 0.0;}
  inline int64_t val_int(void)
          { return 0;}
  inline db_decimal *val_decimal(db_decimal *) { return 0; }

  inline String *val_str(String *, String *value2)
                { value2->length(0); return value2;}
  inline int cmp(const unsigned char *, const unsigned char *) { return 0;}
  void sort_string(unsigned char *, uint32_t)  {}
  inline uint32_t pack_length() const { return 0; }
  void sql_type(String &str) const;
  inline uint32_t size_of() const { return sizeof(*this); }
  inline uint32_t max_display_length() { return 4; }
};

#endif

